import java.util.Scanner;

public class test3181 {
    //评委打分
    public static void main(String[] args) {
     int score[]=  getscore();
     for(int i=0;i<score.length;i++)
            System.out.println(score[i]);
     int max=getmax(score);
     int min=getmin(score);
     int sum=getsum(score);
     int ave= (sum-min-max)/(score.length-2);
     System.out.println(ave);
    }
    //先输入6个100之内的评分
    public static int[] getscore() {
        int[] scores = new int[6];
        Scanner sc = new Scanner(System.in);
        for (int i=0; i<scores.length; ) {
            System.out.println("Enter score: ");
           int score = sc.nextInt();
           if (score <=100&& score>=0) {
               scores[i]=score;
               i++;
           }else {
               System.out.println("Invalid score");
           }

        }
        return scores;
    }
    //找到6个评分中最大的
    public static int getmax(int []scores) {
        int max = scores[0];
        for(int i=1;i<scores.length;i++){
            if(scores[i]>max){
                max = scores[i];
            }
        }
        return max;
    }
    //找到6个评分中最小的
    public static int getmin(int []scores) {
        int min = scores[0];
        for(int i=1;i<scores.length;i++){
            if(scores[i]<min){
                min = scores[i];
            }
        }
        return min;
    }
    //求出评分总和
    public static int getsum(int []scores) {
        int sum = 0;
        for (int i=0; i<scores.length; i++) {
            sum += scores[i];
        }
        return sum;
    }
}
